<template>  <!-- 我的预约页面 -->
	<view>
		<view class="view1" v-for="(v,i) in arr" @click="look(i,v.order_orderId)" :key="i">
			<view class="view1-1">
				<text :style="{color:(v.order_status==0?'green':v.order_status==1?'orange':'grey')}">{{v.user_name}} {{v.user_tel}}</text>
				<text :style="{color:(v.order_status==0?'green':v.order_status==1?'orange':'grey')}">
				{{v.order_status==0?'待体检':v.order_status==1?'待支付':v.order_status==2?'已体检':'已取消'}}
				</text>
			</view>
			<view class="view1-2">
				<view>
					体检机构: <text> {{v.org_Name}}</text>
				</view>
				<view>
					体检时间: <text> {{fromData(v.order_date)}}</text>
				</view>
				<view>
					体检单号: <text> {{v.order_orderId}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arr:[],
				user:{}
			}
		},
		mounted(){
			uni.getStorage({
				key:"userInfo",
				success:(res)=>{
					console.log('用户信息',res.data);
					this.user=res
				}
			})
			this.$http({   //获取我的体检列表
				url:"/getminebooked",
				data:{
					user_tel:15184462493
				}
			}).then((res)=>{
				this.arr=res.data
			})
		},
		methods: {
			fromData(a) {   //后台传前台时间格式转换
			    let time = new Date(a)
			    let month = time.getMonth() + 1 
			    let date = time.getDate()
			    let hours = time.getHours()
			    let minutes = time.getMinutes()
			    // let second = time.getSeconds() // 获取秒数
			    // 小于10前加一个0
			    if(month < 10) {
			      month = '0' + month
			    }
			    if(date < 10) {
			      date = '0' + date
			    }
				return time.getFullYear() + '-' + month + '-' + date 
			},
			
			look(a,b){  //列表页跳转相应页面
				uni.setStorageSync('id', b)
				if(this.arr[a].order_status==0){  //待体检
					uni.navigateTo({
					    url:'/pages/HXM/MineBookedDetails/MineBookedDetails',
					})
				}else if(this.arr[a].order_status==1){  //待支付
					uni.navigateTo({
					    url:'/pages/HXM/AwaitPayment/AwaitPayment',
					})
				}else if(this.arr[a].order_status==2){  //已体检
					uni.navigateTo({
					    url:'/pages/HXM/AccomplishPhysical/AccomplishPhysical',
					})
				}else{
					uni.navigateTo({  //体检预约详情  已取消预约
					    url:'/pages/HXM/CancelRefundDetails/CancelRefundDetails',
					})
				}
			}
		}
	}
</script>

<style lang="less">
	body{
		background: #F8F8F8;
		
	}
	.view1{
		font-size: 12px;
		margin-bottom: 30rpx;
		border-radius: 10rpx;
		background: white;
		margin: 20rpx;
		.view1-1{
			display: flex;
			padding: 30rpx;
			justify-content: space-between;
			border-bottom: 2rpx solid #C1C1C1;
		}
		.view1-2{
			padding: 30rpx;
			view{
				margin-top: 10rpx;
				text{
					margin-left: 20rpx;
				}
			}
		}
	}
	
</style>
